﻿ALTER PROCEDURE [dbo].[usp_comprobantePresentacion]
@Accion as int,
@ComprobantePresentacionId as int,
@ComprobantePresentacionFecha as datetime,
@ComprobantePresentacionDescripcion as varchar(250),
@EmpleadoId as int,
@FarmaciaId as int

AS

IF @Accion = 1 BEGIN
	INSERT INTO ComprobantePresentacion (ComprobantePresentacionFecha, ComprobantePresentacionDescripcion, EmpleadoId, FarmaciaId)
	VALUES (@ComprobantePresentacionFecha, @ComprobantePresentacionDescripcion, @EmpleadoId, @FarmaciaId)
END

SELECT @@IDENTITY

IF @Accion = 2 BEGIN
	UPDATE ComprobantePresentacion
	SET 
	   ComprobantePresentacionFecha = @ComprobantePresentacionFecha,
	   ComprobantePresentacionDescripcion = @ComprobantePresentacionDescripcion,
	   EmpleadoId = @EmpleadoId,
	   FarmaciaId = @FarmaciaId
	WHERE ComprobantePresentacionId = @ComprobantePresentacionId
END

IF @Accion = 3 BEGIN
	DELETE FROM ComprobantePresentacion
	WHERE ComprobantePresentacionId = @ComprobantePresentacionId
END
